/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.comac.ins.common.core.utils.StringUtils;
import com.comac.ins.isfd.domain.IsfdMeshOp2CompareItemDefault;
import com.comac.ins.isfd.domain.bo.IsfdMeshOp2CompareItemDefaultBo;
import com.comac.ins.isfd.domain.vo.IsfdMeshOp2CompareItemDefaultVo;
import com.comac.ins.isfd.mapper.IsfdMeshOp2CompareItemDefaultMapper;
import com.comac.ins.isfd.service.IIsfdMeshOp2CompareItemDefaultService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 自然网格对比默认条目Service业务层处理
 *
 * @author hxloongs
 * @date 2025-04-21
 */
@RequiredArgsConstructor
@Service
public class IsfdMeshOp2CompareItemDefaultServiceImpl implements IIsfdMeshOp2CompareItemDefaultService {

    @Autowired
    private IsfdMeshOp2CompareItemDefaultMapper baseMapper;


    @Override
    public IsfdMeshOp2CompareItemDefaultVo queryById(Long id) {
        return baseMapper.selectVoById(id);
    }


    @Override
    public List<IsfdMeshOp2CompareItemDefaultVo> queryList(IsfdMeshOp2CompareItemDefaultBo bo) {
        LambdaQueryWrapper<IsfdMeshOp2CompareItemDefault> lqw = buildQueryWrapper(bo);
        return baseMapper.selectVoList(lqw);
    }

    private LambdaQueryWrapper<IsfdMeshOp2CompareItemDefault> buildQueryWrapper(IsfdMeshOp2CompareItemDefaultBo bo) {
        LambdaQueryWrapper<IsfdMeshOp2CompareItemDefault> lqw = Wrappers.lambdaQuery();
        lqw.like(StringUtils.isNotBlank(bo.getItemName()), IsfdMeshOp2CompareItemDefault::getItemName, bo.getItemName());
        lqw.eq(StringUtils.isNotBlank(bo.getItemCode()), IsfdMeshOp2CompareItemDefault::getItemCode, bo.getItemCode());
        lqw.eq(StringUtils.isNotBlank(bo.getMatchKey()), IsfdMeshOp2CompareItemDefault::getMatchKey, bo.getMatchKey());
        return lqw;
    }

}
